<?php

/* @var $this yii\web\View */

use yii\helpers\Url;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\helpers\Render;
use common\models\User;

$this->addCrumbs('设计师列表', 'user/user-designer');
$this->title = (isset($data['id']) ? '修改' : '添加'). '设计师';
?>

<div class="box-content gap">
    <div class="warn success mb">
        <p>备注: </p>
        <p>1、如果填写密码表示修改，否则请保持为空</p>
    </div>
    <form class="flyer-form pane" id="flyer-create" action="<?= Url::to('@web/user/user-').(isset($data['id']) ? 'update?id='.$data['id'] : 'insert') ?>" method="post">
        <div class="form-item checker">
            <div class="input-title">登录帐号</div>
            <div class="input-block"><input class="flyer-input" type="text" name="username" value="<?= Render::value($data, 'username') ?>" placeholder="user name." <?= isset($data['id']) ? 'readonly' : '' ?>></div>
        </div>
        <div class="form-item checker">
            <div class="input-title">密码</div>
            <div class="input-block"><input class="flyer-input" type="password" name="password_digest" value="" placeholder="password."></div>
        </div>
        <div class="form-item checker">
            <div class="input-title">昵称</div>
            <div class="input-block"><input class="flyer-input" type="text" name="nickname" value="<?= Render::value($data, 'nickname') ?>" placeholder="nick name."></div>
        </div>
        <div class="form-item checker">
            <div class="input-title">手机</div>
            <div class="input-block"><input class="flyer-input" type="text" name="mobile" value="<?= Render::value($data, 'mobile') ?>" placeholder="mobile."></div>
        </div>
        <div class="form-item">
            <div class="input-block tr bdn"><button class="flyer-button normal border-round" id="save-button" type="submit"><i class="icon-save"></i> 保 存</button></div>
            <textarea id="flyer-create-json" data-form="#flyer-create" style="display:none;"><?= $relate ?></textarea>
        </div>
        <input type="hidden" name="_csrf" value="<?=Yii::$app->request->getCsrfToken() ?>">
    </form>
</div>

<script src="<?= Render::static('flyer/flyer.class.js') ?>"></script>
<script src="<?= Render::static('flyer/checker.class.js') ?>"></script>
<script>
    $(document).ready(function() {
        // Form 元素初始化
        (new flyer).init({form: '#flyer-create'});

        // 表单数据验证
        (new checker).init({ruleDom: '#flyer-create-json'});
    });
</script>